package com.ctshk.sapp.visa.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.visa.dto.visa.*;
import com.ctshk.rpc.visa.req.visa.*;
import com.ctshk.rpc.visa.service.IVisaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 签证资源 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-20
 */
@Api(value="预订、资源中心签证", tags="预订、资源中心签证")
@RestController
@RefreshScope
@RequestMapping("/visa")
public class VisaController extends BaseController {
    @DubboReference
    private IVisaService iVisaService;

    @ApiOperation(value="签证详情", notes="签证详情(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "签证详情", operDesc = "签证详情")
    @PostMapping("/info")
    public Result<VisaInfoResp> visaInfo(@RequestBody @Valid VisaInfoReq visaInfoReq) {
        return iVisaService.query(visaInfoReq);
    }

    @ApiOperation(value="资源中心签证列表", notes="签证列表(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "签证列表", operDesc = "签证列表")
    @PostMapping("/list")
    public Result<PageResponse<VisaListDTO>> visaList(@RequestBody VisaListReq visaListReq) {
        PageResponse<VisaListDTO> list = iVisaService.list(visaListReq);
        return Result.success(list);
    }


    @ApiOperation(value="修改状态", notes="修改状态")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.UPDATE, operTitle = "修改状态", operDesc = "修改状态")
    @PutMapping("/update")
    public Result put(@RequestBody VisaUpdateReq visaUpdateReq) {
        return Result.success(iVisaService.update(visaUpdateReq));
    }

    @ApiOperation(value="保存签证办理", notes="保存签证办理(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.ADD, operTitle = "保存签证办理", operDesc = "保存签证办理")
    @PostMapping("/save-visa")
    public Result saveVisa(@RequestBody @Valid VisaSaveReq visaSaveReq) {
        TokenUser user = getCurrentUser(getRequest());
        return Result.success(iVisaService.add(visaSaveReq,user));
    }

    @ApiOperation(value="签证售卖列表", notes="签证售卖列表(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "签证列表", operDesc = "签证列表")
    @PostMapping("/sell-list")
    public Result<PageResponse<VisaSellListRespDTO>> visaSellList(@RequestBody VisaListReq visaListReq) {
        PageResponse<VisaSellListRespDTO> list = iVisaService.sellList(visaListReq);
        return Result.success(list);
    }

    @ApiOperation(value="签证售卖列表2", notes="签证售卖列表2(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "签证列表", operDesc = "签证列表")
    @PostMapping("/sell-list2")
    public Result<PageResponse<VisaSellListDTO>> visaSellList2(@RequestBody VisaListReq visaListReq) {
        return Result.success(iVisaService.sellList2(visaListReq));
    }

    @ApiOperation(value="行程详情签证列表", notes="行程详情签证列表(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "行程详情签证列表", operDesc = "行程详情签证列表")
    @PostMapping("/visa-list")
    public Result<List<VisaListDTO>> list(@RequestBody VisaListReq visaListReq){
        return iVisaService.visaList(visaListReq);
    }

    /**
     * 预订中心签证办理详情
     * @param visaInfoReq
     * @return
     */
    @ApiOperation(value="预订中心签证办理详情", notes="预订中心签证办理详情(陈雷))")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "签证详情", operDesc = "签证详情")
    @PostMapping("/handle-info")
    public Result<VisaHandleResp> visaHandleQuery(@RequestBody @Valid VisaInfoReq visaInfoReq) {
        return iVisaService.visaHandleQuery(visaInfoReq);
    }

    /**
     * 团订单（旅行团、定制包团）
     * @param visaListReq
     * @return
     */
    @ApiOperation(value="团订单（旅行团、定制包团）列表", notes="团订单（旅行团、定制包团）列表(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "团订单（旅行团、定制包团）列表", operDesc = "团订单（旅行团、定制包团）列表")
    @PostMapping("/visa-group-list")
    public Result<List<VisaListGroupDTO>> groupList(@RequestBody VisaListReq visaListReq){
        return iVisaService.visaGroupList(visaListReq);
    }

    /**
     * 团订单（旅行团、定制包团）获取价格
     * @param visaGroupPriceReq
     * @return
     */
    @ApiOperation(value="团订单（旅行团、定制包团）获取价格", notes="团订单（旅行团、定制包团）获取价格(陈雷)")
    @OperationLogAnnotation(operModul = OperationLogModel.VISA, operType = OperationLogType.QUERY, operTitle = "团订单（旅行团、定制包团）获取价格", operDesc = "团订单（旅行团、定制包团）获取价格")
    @PostMapping("/visa-group-price")
    public Result<VisaGroupDetailDTO> groupPrice(@RequestBody VisaGroupPriceReq visaGroupPriceReq){
        return iVisaService.visaGroupDetail(visaGroupPriceReq);
    }
}
